import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import Cookies from 'js-cookie'
import App from './App'
import router from './router'
import store from './store'
import '@/icons' // icon
import '@/permission' // 权限
import "babel-polyfill";
import VueI18n from 'vue-i18n'

Vue.use(VueI18n)

// const locale = store.getters.language
// const localeMap = {
//   "en": enLocale,
//   "zh-cn": zhLocale
// }

const i18n = new VueI18n({
  locale: Cookies.get('language') || 'zh-cn',
  messages: {
    "en": {
      ...enLocale
    },
    "zh-cn": {
      ...zhLocale
    }
  }
})
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})


Vue.config.productionTip = false

export const vm = new Vue({
  el: '#app',
  i18n,
  router,
  store,
  template: '<App/>',
  components: { App }
})
